/*
 * @Description: 全局自定义提示的工具，为了满足产品的定制需求
 * @Author: hmt
 * @Date: 2022-09-22 16:20:47
 * @LastEditors: hmt
 * @LastEditTime: 2024-03-27 15:27:37
 */
import { ElMessage } from 'element-plus'

type MessageType = 'success' | 'info' | 'warning' | 'error'

const DEAD = {
  offset: 60, // 主要是鼠标在消息上的时候，消息不会关闭，把它往下移动，不要挡住头部栏目
  duration: 1.2 * 1000 // 产品要求3秒结束，但是默认本来就是3秒，偷偷改成1.2秒吧
}

const message = (message: string, type: MessageType) => {
  ElMessage({
    message,
    type,
    ...DEAD
  })
}

const ShopMessage = {
  success: (msg: string) => message(msg, 'success'),
  error: (msg: string) => message(msg, 'error'),
  warning: (msg: string) => message(msg, 'warning'),
  info: (msg: string) => message(msg, 'info'),
  html: (options: object) => ElMessage({ ...options, ...DEAD })
}

export default ShopMessage
